<template>
  <el-tabs v-model="activeName">
    <el-tab-pane label="线索评级" name="clueLevel">
      <div>
        <FormPanel ref="formPanel3" :list="formList3" :cols="1" :formType="type" labelWidth="180" :isSubmitBtn="false" />
      </div>
    </el-tab-pane>
    <el-tab-pane label="用户画像" name="userPortrait">
      <div>
        <FormPanel ref="formPanel4" :list="formList4" :cols="3" :formType="type" labelWidth="150" :isSubmitBtn="false" />
      </div>
    </el-tab-pane>
  </el-tabs>
</template>

<script>
import { queryClueSourceList, getOrgType, getDealerArea, getCompanyOrgIsMerge } from '@/api/potenCus/customer/potenCusManage';
import { addNewClues, getClueById, getTemperatureList, getMapCmsInfo } from '@/api/potenCus/customer/potenCusManageOEM';
import { getBrandList, getSeriesList, getModelList, getPackageList, getOptionList, getColorsList } from '@/api/potenCus/basedata/searchTestDriveCars';
import { getlistAllData } from '@/api/common/org/dealerCompany'; //城市接口
import AjaxButton from '@/components/AjaxButton';
import { dictionary } from '@/utils/dictMixin';
import { authority } from '@/utils/authMixin';
import searchDealers from './addOEMdiaolg/searchDealers';
import { phone, formatDates, formatDat, checkPassport } from '@/utils/validate';
import { getAppId } from '@/assets/js/auth';

export default {
  name: 'clueLevelModel',
  mixins: [dictionary, authority],
  components: {
    searchDealers
  },
  props: {
    type: {
      type: String,
      default: 'add'
    },
    rowData: {
      type: Object,
      default: () => ({})
    }
  },
  data() {
    this.saveData = null;
    return {
      activeName: 'clueLevel',
      formList3: this.createFormList3(),
      formList4: this.createFormList4(),
      clueLevel: null,
      handleType: '',
      isShow: true,
      allOrgId: []
    };
  },
  created() {
    this.init();
  },
  methods: {
    async init() {
      //与map接口相关数据展示
      let phone = this.rowData.phone;
      if (phone == null || phone == undefined) {
        phone = this.rowData.mobilePhone;
      }
      const resMap = await getMapCmsInfo({ mobile: phone, appId: getAppId() });
      if (resMap.resultCode == 200) {
        if (resMap.data != null) {
          this.formList3.forEach(x => {
            if (x.fieldName == 'clueLevel') {
              this.clueLevel = resMap.data[x.fieldName];
            }
            if (resMap.data[x.fieldName]) {
              x.initialValue = resMap.data[x.fieldName];
            }
          });
          this.formList4.forEach(x => {
            if (resMap.data[x.fieldName]) {
              x.initialValue = resMap.data[x.fieldName];
            }
          });
        }
      }
    },

    // 线索评级
    createFormList3() {
      return [
        {
          type: 'INPUT',
          label: '线索评级等级',
          fieldName: 'clueLevel',
          // hidden: true,
          render: props => {
            return <el-rate disabled={true} v-model={this.clueLevel}></el-rate>;
          },
          disabled: true
        },
        {
          type: 'INPUT',
          label: '线索评级得分',
          fieldName: 'clueScore',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '线索评级身份得分',
          fieldName: 'clueDataScore',
          disabled: true
        },

        {
          type: 'INPUT',
          label: '线索评级行为得分',
          fieldName: 'clueTagScore',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '沟通热度',
          fieldName: 'communicationLevel',
          disabled: true
        },
        // {
        //   type: 'INPUT',
        //   label: '意向匹配度',
        //   fieldName: 'tempwst1',
        //   disabled: true
        // },
        {
          type: 'INPUT',
          label: '复购意向',
          fieldName: 'repurchaseLevel',
          disabled: true
        }
      ];
    },
    // 用户画像
    createFormList4() {
      return [
        {
          type: 'INPUT',
          label: '客户类型',
          fieldName: 'customerType',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '人群标签',
          fieldName: 'cdpTag',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '人群圈选标识名称',
          fieldName: 'audienceName',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '姓名',
          fieldName: 'name',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '性别',
          fieldName: 'gender',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '昵称',
          fieldName: 'nickName',
          disabled: true
        },
        // {
        //   type: 'INPUT',
        //   label: 'vin号',
        //   fieldName: 'vin',
        //   disabled: true
        // },
        // {
        //   type: 'INPUT',
        //   label: '微信openid',
        //   fieldName: 'TEMPWST3',
        //   disabled: true
        // },
        {
          type: 'INPUT',
          label: '生日',
          fieldName: 'birthday',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '省份',
          fieldName: 'province',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '城市',
          fieldName: 'city',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '职业',
          fieldName: 'occupation',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '学历',
          fieldName: 'education',
          disabled: true
        },
        {
          type: 'INPUT',
          label: '婚姻',
          fieldName: 'marriage',
          disabled: true
        }
        // {
        //   type: 'INPUT',
        //   label: '手机号码',
        //   fieldName: 'mobile',
        //   disabled: true
        // },
        // {
        //   type: 'INPUT',
        //   label: '身份证',
        //   fieldName: 'TEMPWST5',
        //   disabled: true
        // }
      ];
    }
  }
};
</script>

<style lang="less" scoped>
::v-deep .el-tabs__content {
  margin-top: 10px;
}
</style>
